package com.bsoft.project.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.bsoft.project.service.DzfpUploadService;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: 褚国强
 * @Date: 2020/07/08/22:28
 * @Description:
 */
@RestController
@RequestMapping("dzfp")
public class DzfpUploadController {

	 private final Logger logger = LoggerFactory.getLogger(DzfpUploadController.class);

	@Autowired
	private DzfpUploadService service;
	
	
	// 数据库测试
	@RequestMapping(value = "getDzfpUploadList", method = RequestMethod.GET)
	public List<HashMap<String, Object>> dzfpUpload() {
		List<HashMap<String, Object>> result = service.getDzfpUploadList();
		return result;
	}

	// 电子发票接受 模拟
	@RequestMapping(value = "dzpfAccept", method = RequestMethod.POST)
	public HashMap<String, Object> dzpfAccept() {
		HashMap<String, Object> result = new HashMap<String, Object>();
		result.put("code", 0);
		result.put("message", "success!");
		result.put("data", null);
		return result;
	}

	/**
	 * @author : 褚国强
	 * @date 创建时间：2021年7月29日
	 * @Description: 发送财政单位端票据开具日报
	 * @version 1.0
	 * @parameter
	 * @since
	 * @return
	 */
	@RequestMapping(value = "dzfpDailyReport", method = RequestMethod.POST)
	public HashMap<String, Object> dzfpDailyReport() {
		HashMap<String, Object> result = new HashMap<String, Object>();
		try {
			return service.dzfpDailyReport();
		} catch (Exception e) {
			result.put("code", 500);
			result.put("message", "error!");
			logger.error(e.getMessage(), e);
		}
		logger.info("---------------------" + JSON.toJSONString(result));
		return result;
	}

	/**
	 * @author : 褚国强
	 * @date 创建时间：2021年7月29日
	 * @Description: 发送医院his端实际缴款日报
	 * @version 1.0
	 * @parameter
	 * @since
	 * @return
	 */
	@RequestMapping(value = "dzfpHisDailyReport", method = RequestMethod.POST)
	public HashMap<String, Object> dzfpHisDailyReport() {
		HashMap<String, Object> result = new HashMap<String, Object>();
		try {
			return service.dzfpHisDailyReport();
		} catch (Exception e) {
			result.put("code", 500);
			result.put("message", "error!");
			logger.error(e.getMessage(), e);
		}
		logger.info("---------------------" + JSON.toJSONString(result));
		return result;
	}

	/**
	 * @author : 褚国强
	 * @date 创建时间：2021年7月29日
	 * @Description: 发起电子票据签名请求（单位无签名服务器）
	 * @version 1.0
	 * @parameter
	 * @since
	 * @return
	 */
	@RequestMapping(value = "setEInvoiceInfoForEnter", method = RequestMethod.POST)
	public HashMap<String, Object> setEInvoiceInfoForEnter() {
		HashMap<String, Object> result = new HashMap<String, Object>();
		try {
			return service.setEInvoiceInfoForEnter();
		} catch (Exception e) {
			result.put("code", 500);
			result.put("message", "error!");
			logger.error(e.getMessage(), e);
		}
		logger.info("---------------------" + JSON.toJSONString(result));
		return result;
	}

	/**
	 * @author : 褚国强
	 * @date 创建时间：2021年7月29日
	 * @Description: 发起电子票据签名请求（单位有签名服务器）
	 * @version 1.0
	 * @parameter
	 * @since
	 * @return
	 */
	@RequestMapping(value = "setEInvoiceInfo", method = RequestMethod.POST)
	public HashMap<String, Object> setEInvoiceInfo() {
		HashMap<String, Object> result = new HashMap<String, Object>();
		try {
			return service.setEInvoiceInfo();
		} catch (Exception e) {
			result.put("code", 500);
			result.put("message", "error!");
			logger.error(e.getMessage(), e);
		}
		logger.info("---------------------" + JSON.toJSONString(result));
		return result;
	}

	/**
	 * @author : 褚国强
	 * @date 创建时间：2021年11月09日
	 * @Description:  医保目录下载测试
	 * @version 1.0
	 * @parameter
	 * @since
	 * @return
	 */
	@RequestMapping(value = "rsfComIfsService", method = RequestMethod.POST)
	public HashMap<String, Object> rsfComIfsService(@RequestParam HashMap<String,Object> param) {
		HashMap<String, Object> result = new HashMap<String, Object>();
		try {
			return service.rsfComIfsService(param);
		} catch (Exception e) {
			result.put("code", 500);
			result.put("message", "error!");
			logger.error(e.getMessage(), e);
		}
		logger.info("---------------------" + JSON.toJSONString(result));
		return result;
	}
}
